#ifndef DEBUG_H

/* set output of log */
#if !defined(DEBUG_OUTPUT_PRINTF) && !defined(DEBUG_OUTPUT_ALOG) && !defined(DEBUG_OUTPUT_ALOG_SYS)
/*#	define DEBUG_OUTPUT_PRINTF*/
/*#	define DEBUG_OUTPUT_ALOG_SYS*/
#	define DEBUG_OUTPUT_ALOG_NDK
#endif /* !defined(DEBUG_OUTPUT_PRINTF) && !defined(DEBUG_OUTPUT_ALOG) */

#if !defined(LOG_NDEBUG) || !LOG_NDEBUG
#	ifdef DEBUG_OUTPUT_PRINTF
#		include <stdio.h>
#		define DEBUG_PRINT(fmt, args...) do{fprintf(stdout, "%s: ", LOG_TAG); fprintf(stdout, fmt"\n", ##args);fflush(stdout);}while(0)
#		define ERROR_PRINT(fmt, args...) do{fprintf(stderr, "%s: ", LOG_TAG); fprintf(stderr, fmt"\n", ##args);fflush(stderr);}while(0)
#	else
#		ifndef LOG_TAG
#			define LOG_TAG "DEFAULT_LOG_TAG"
#		endif
#		ifdef DEBUG_OUTPUT_ALOG_NDK
#			include <android/log.h>
#			define ALOGD(fmt,args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ##args)
#			define ALOGE(fmt,args...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, fmt, ##args)
#		else
#			include <utils/Log.h>
#		endif
#		define DEBUG_PRINT ALOGD
#		define ERROR_PRINT ALOGE
#	endif
#	if !defined(LOG_NTRACE) || !LOG_NTRACE
#		define FUNC_ENTER() DEBUG_PRINT("[E] %s", __func__)
#		define FUNC_EXIT() DEBUG_PRINT("[X] %s", __func__)
#	else
#		define FUNC_ENTER()
#		define FUNC_EXIT()
#	endif
#	define MARK() DEBUG_PRINT("%s %d", __func__, __LINE__)
#	define MARK_STATUS(status) DEBUG_PRINT("%s %d %s", __func__, __LINE__, (status))
#else
#	define DEBUG_PRINT(fmt,args...)
#	define ERROR_PRINT(fmt,args...)
#	define FUNC_ENTER()
#	define FUNC_EXIT()
#	define MARK()
#	define MARK_STATUS(status)
#endif /* !defined(LOG_NDEBUG) || !LOG_NDEBUG */

#endif /* DEBUG_H */
